package com.duqc.tag.service.impl;

import com.duqc.tag.dao.TagDataMapper;
import com.duqc.tag.entity.TagData;
import com.duqc.tag.entity.TagRule;
import com.duqc.tag.service.TagDataService;
import com.duqc.util.DateUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName TagDataServiceImpl
 * @Description TagDataServiceImpl
 * @Author duqc
 * @Date 2023/2/15
 **/
@Slf4j
@Service
@RequiredArgsConstructor
public class TagDataServiceImpl implements TagDataService {

    private final TagDataMapper tagDataMapper;

    /**
     * 删除标签数据
     *
     * @param tagId 标签ID
     */
    @Override
    public void deleteByTagId(Long tagId) {
        this.tagDataMapper.deleteByTagId(tagId);
    }

    /**
     * 保存标签信息
     *
     * @param intersection 标签数据
     * @param tagRule      标签信息
     */
    @Override
    public void saveTagData(List<String> intersection, TagRule tagRule) {
        TagData tagData = new TagData();
        tagData.setTagId(tagRule.getTagId());
        tagData.setTagName(tagRule.getTagName());
        tagData.setCreateTime(DateUtils.getNow());
        this.tagDataMapper.saveTagData(intersection, tagData);
    }
}
